#ifndef BUDDYLIST_H
#define BUDDYLIST_H

#include <QtGui/QDialog>
#include <QWidget>
#include "clientHandler.h"
#include <QVector>
#include "chatwindow.h"

/*! \brief BuddyList
  This class handles the functions of and
relating to the buddy list.
  */

namespace Ui {
    class BuddyList;
}

class BuddyList : public QDialog {
    Q_OBJECT

public:

    /*! BuddyList
      \brief constructor
      */
    BuddyList(QWidget *parent = 0);

    /*! ~BuddyList
      \brief deconstructor
      */
    ~BuddyList();

    /*! closeEvent
      \brief closes a window
      \param event pointer to a closeEvent
      */
    void closeEvent(QCloseEvent *event);

    /*! \var QString userName
      \brief the username of the logged in user
      */
    QString userName;

    /*! \var status
      \brief the status of the logged in user
      */
    QString status;

    /*! \var QVector<ChatWindow *> openWindows
      \brief a vector that stores all open chat windows
      */
    QVector<ChatWindow *> openWindows;

    /*! \var QVector<QString> allMyBuddies
      \brief vector of all of the user's buddies
      */
    QVector<QString> allMyBuddies;

       /*! removeWindow
      \brief removes a window when you press 'X'
      */
    void removeWindow(QString nameOfContact);

        /*! popUp
      \brief pops up a new chat window onto screen
      */
    void popUp();


    //QString *item;

    /*! populateList
      \brief displays the buddy list
      */
    void populateList();

protected:

    /*! changeEvent
      \brief detects an event change
      \param e pointer to QEvent
      */
    void changeEvent(QEvent *e);

private slots:

    //void clickedAddContact();

    /*! okayToClose
      \brief pops up an a window warning that the chat is about to close
      */
    bool okayToClose();

    /*! setStatus
      \brief lists the status of the buddies
      */
    void setStatus();

    /*! checkWindowStatus
      \brief checks if a window is closed of already open
      */
    void checkWindowStatus();

    /*! newChatDialog
      \brief opens a new chat window
      */
    void newChatDialog();

    /*! clickedRemoveContact
      \brief detects if remove buddy button is clicked
      */
    void clickedRemoveContact();

        /*! clickedAddContact
      \brief detects teh clicking of the add contact button
      */
    void clickedAddContact();

       /*! removeWindow
      \brief removes a window when you press 'X'
      */
    void removeWindow();

    /*! oneWindowPerBuddy
      \brief makes sure hat only one chat window is open for each buddy
      */
    void oneWindowPerBuddy();

    /*! windowAlreadyOpen
      \brief detects if a chat window is already open when a user clicks on a buddy
      */
    bool windowAlreadyOpen();

    /*! incomingAlreadyOpen
      \brief detects if detects if a chat window is already open when a buddy chats with
      a user
      */
    bool incomingAlreadyOpen();



private:

    /*! \var Ui::BuddyList *m_ui
      \brief pointer to Buddy List UI
      */
    Ui::BuddyList *m_ui;


};
#endif // BUDDYLIST_H
